<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="./layui/css/layui.css">
</head>
<style>
    .mxnW{
        width: 80%;
        margin: 0 auto;
        margin-top: 20px;
    }
    select{
        width: 100%;
        height: 38px;
        line-height: 38px;
        line-height: 36px\9;
        border: 1px solid #e6e6e6;
        background-color: #fff;
        border-radius: 2px;
    }
    .center-block {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-bottom: 10px;
    }
</style>
<body>
<form class="layui-form mxnW" action="" >
    <div class="layui-form-item">
        <label class="layui-form-label">团队</label>
        <div class="layui-input-block">
            <select name="city" onchange="change()" id="teamToProject" lay-ignore lay-verify="required">
                <option value=""></option>
            </select>
        </div>
    </div>
    <hr>
    <!--二维码-->
    <div class="layui-form-item">
        <div id="qrcode" class="center-block">

        </div>
        <label class="layui-form-label">邀请链接</label>
        <div class="layui-input-block">
            <input type="text" name="" id="yaoText"  required  placeholder="邀请链接" class="layui-input">
        </div>
    </div>
</form>
<script src="../../public/js/jquery.min.js"></script>
<script src="./layui/layui.js"></script>
<script src="../../public/js/jquery.qrcode.js"></script>
<script>
    $.ajax({
        type: 'POST',
        url:"/team/search",
        data: {data:{key:'userid',value:JSON.parse(sessionStorage.user).userid}},
        success:function (data) {
            console.log(data)
            for(var i=0;i<data.result.length;i++){
                $("#teamToProject").append(
                    '<option value='+data.result[i].teamid+'>'+data.result[i].title+'</option>'
                )
            }
        } ,
        error:function () {
            layer.msg("系统错误")
        }
    })
</script>
<script>
    layui.use('form', function(tpl){
        var form = layui.form();
        //监听提交

    });
    function change() {
        if($("#teamToProject").val()){
            var yaoHref = location.origin+"/webpack/src/pages/layer/inTeam.html?"+$("#teamToProject").val();
            $("#qrcode").html("");
            $('#qrcode').qrcode(yaoHref);
            $("#yaoText").val(yaoHref);
        }else{
            $("#qrcode").html("");
            $("#yaoText").val("请选择团队");
        }
    }
    change();
</script>
</body>
</html>